package com.ruoyi.web.controller.app.pay.wechat.controller;


import com.ruoyi.web.controller.app.pay.util.ResultMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xml.sax.SAXException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.Map;

/**
 * 微信支付
 */
@Controller
@RequestMapping(value = "wxpay")
public class WxPayController {
	private static final Logger logger = LoggerFactory.getLogger(WxPayController.class);
	/*@Autowired
	private IWeixinPayService weixinPayService;
*/
	@Autowired
    HttpServletRequest request;

	@ResponseBody
	@RequestMapping(value="appPay",method= RequestMethod.POST)
    public Map<String,Object> appPay(String userId,Long orderId) {
		logger.info("app微信支付服务端");
		try {
			return null;
			//return ResultMap.getSuccessMap(weixinPayService.appPay(userId,orderId,request));
		}catch (IllegalArgumentException e) {
			return ResultMap.getFailMap("失败，" + e.getMessage());
		} catch (Exception e) {
			return ResultMap.getFailMap("系统错误," + e.getMessage());
		}

	}


	@RequestMapping("/notifyUrl")
	public void notifyUrl(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, SAXException {
		//1、weixinPayService.notifyUrl(request,response);
	}


}
